#include <boost/extension/extension.hpp>
#include <PFileInfo.h>
#include <cstring>
#include "Docxconv.h"

/* Docx Convert Plugin Entry Point
* 
* Predstavuje vstupny bod do dynamicky linked library.
* Nato aby Konverzny modul vedel pracovat s toutou dll-kou
* vsetky nasledujuce metody musia byt pristupne a implementovane.
*
*/

//vytvorime globalny objekt ktory potom bude volany z prislusnich funkcii
Docxconv converter;


extern "C"
bool BOOST_EXTENSION_EXPORT_DECL Open(PComunicator::PFileInfo &theFile)
{
	return converter.Open(theFile);
}

extern "C"
char BOOST_EXTENSION_EXPORT_DECL *Format(void)
{
	return "docx";
}

extern "C"
wchar_t BOOST_EXTENSION_EXPORT_DECL *Read(void) 
{
	std::wstring _res = converter.Read();
	wchar_t *result = new wchar_t[_res.size()];
	wcscpy(result,_res.c_str());	
	return result;
}


extern "C"
char BOOST_EXTENSION_EXPORT_DECL *CreateHtml(const char* thePath)
{
	std::string _ret = converter.CreateHtml(thePath);
	char *result = new char[_ret.size()];
	strcpy(result,_ret.c_str());
	return result;
}


extern "C"
char BOOST_EXTENSION_EXPORT_DECL *Version(void)
{
	return converter.Version();
}


extern "C"
char BOOST_EXTENSION_EXPORT_DECL *Autor(void)
{
	return converter.Autor();
}